﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Dot.cs" company="">
//   
// </copyright>
// <summary>
//   The dot.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Graphix.Elements
{
    using System.Drawing;

    using SvgNet.SvgGdi;

    /// <summary>
    /// The dot.
    /// </summary>
    public class Dot : BaseElement
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="Dot"/> class.
        /// </summary>
        /// <param name="x">
        /// The x.
        /// </param>
        /// <param name="y">
        /// The y.
        /// </param>
        /// <param name="size">
        /// The size.
        /// </param>
        /// <param name="color">
        /// The color.
        /// </param>
        /// <param name="group">
        /// The group.
        /// </param>
        public Dot(float x, float y, float size, Brush color = null)
            : base(x, y, color)
        {
            this.Size = size;
            if (color != null)
            {
                this.BorderColor = new Pen(color);
            }
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the border color.
        /// </summary>
        public Pen BorderColor { get; set; }

        /// <summary>
        /// Gets or sets the size.
        /// </summary>
        public float Size { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The draw.
        /// </summary>
        /// <param name="graphics">
        /// The graphics.
        /// </param>
        public override void Draw(IGraphics graphics)
        {
            Color temp = new Pen(this.Color).Color;
            temp = System.Drawing.Color.FromArgb((int)(temp.A * this.Opacity), temp.R, 
                temp.G, temp.B);

            this.Color = new SolidBrush(temp);

            graphics.FillEllipse(this.Color, this.Position.X, this.Position.Y,
                this.Size, this.Size, this.Attributes);

            if (this.BorderColor != null)
            {
                temp = this.BorderColor.Color;
                this.BorderColor.Color = System.Drawing.Color.FromArgb(
                    (int)(temp.A * this.Opacity), temp.R, 
                    temp.G, temp.B);
                graphics.DrawEllipse(this.BorderColor, this.Position.X, this.Position.Y,
                    this.Size, this.Size, this.Attributes);
            }
        }

        #endregion
    }
}